| Disk ARchive 2.8.1 Full featured and portable backup and archiving tool

Loading...
Searching...
No Matches
scrambler.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2025 Denis Corbin
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18//
19// to contact the author, see the AUTHOR file
20/*********************************************************************/
21
25
26#ifndef SCRAMBLER_HPP
27#define SCRAMBLER_HPP
28
29#include "../my_config.h"
30#include <string>
31#include "infinint.hpp"
32#include "generic_file.hpp"
33#include "erreurs.hpp"
34#include "secu_string.hpp"
35
36 namespace libdar
37{
38
41
42
44
45 class scrambler : public generic_file
46 {
47 public:
48 scrambler(const secu_string & pass, generic_file & hidden_side);
49 scrambler(const scrambler & ref) = delete;
50 scrambler(scrambler && ref) noexcept = delete;
51 scrambler & operator = (const scrambler & ref) = delete;
52 scrambler & operator = (scrambler && ref) noexcept = delete;
53 ~scrambler() { if(buffer != nullptr) delete [] buffer; };
54
55
56 virtual bool skippable(skippability direction, const infinint & amount) override { if(ref == nullptr) throw SRC_BUG; return ref->skippable(direction, amount); };
57 virtual bool skip(const infinint & pos) override { if(ref == nullptr) throw SRC_BUG; return ref->skip(pos); };
58 virtual bool skip_to_eof() override { if(ref == nullptr) throw SRC_BUG; return ref->skip_to_eof(); };
59 virtual bool skip_relative(S_I x) override { if(ref == nullptr) throw SRC_BUG; return ref->skip_relative(x); };
60 virtual bool truncatable(const infinint & pos) const override { if(ref == nullptr) throw SRC_BUG; return ref->truncatable(pos); };
61 virtual infinint get_position() const override { if(ref == nullptr) throw SRC_BUG; return ref->get_position(); };
62
63 protected:
64 virtual void inherited_read_ahead(const infinint & amount) override { if(ref == nullptr) throw SRC_BUG; ref->read_ahead(amount); };
65 virtual U_I inherited_read(char *a, U_I size) override;
66 virtual void inherited_write(const char *a, U_I size) override;
67 virtual void inherited_truncate(const infinint & pos) override { if(ref == nullptr) throw SRC_BUG; ref->truncate(pos); };
68 virtual void inherited_sync_write() override {}; // nothing to do
69 virtual void inherited_flush_read() override {}; // nothing to do
70 virtual void inherited_terminate() override {}; // nothing to do
71
72 private:
73 secu_string key;
74 U_I len;
75 generic_file *ref;
76 unsigned char *buffer;
77 U_I buf_size;
78 };
79
81
82} // end of namespace
83
84#endif
libdar::generic_file
this is the interface class from which all other data transfer classes inherit
Definition generic_file.hpp:77
libdar::generic_file::truncate
virtual void truncate(const infinint &pos)
truncate file at the given offset
libdar::generic_file::read_ahead
void read_ahead(const infinint &amount)
libdar::infinint
the arbitrary large positive integer class
Definition real_infinint.hpp:62
libdar::scrambler
scrambler is a very weak encryption scheme
Definition scrambler.hpp:46
libdar::scrambler::inherited_write
virtual void inherited_write(const char *a, U_I size) override
implementation of the write() operation
libdar::scrambler::skippable
virtual bool skippable(skippability direction, const infinint &amount) override
whether the implementation is able to skip
Definition scrambler.hpp:56
libdar::scrambler::get_position
virtual infinint get_position() const override
get the current read/write position
Definition scrambler.hpp:61
libdar::scrambler::skip_to_eof
virtual bool skip_to_eof() override
skip to the end of file
Definition scrambler.hpp:58
libdar::scrambler::inherited_read_ahead
virtual void inherited_read_ahead(const infinint &amount) override
tells the object that several calls to read() will follow to probably obtain at least the given amoun...
Definition scrambler.hpp:64
libdar::scrambler::inherited_terminate
virtual void inherited_terminate() override
destructor-like call, except that it is allowed to throw exceptions
Definition scrambler.hpp:70
libdar::scrambler::inherited_sync_write
virtual void inherited_sync_write() override
write down any pending data
Definition scrambler.hpp:68
libdar::scrambler::inherited_flush_read
virtual void inherited_flush_read() override
reset internal engine, flush caches in order to read the data at current position
Definition scrambler.hpp:69
libdar::scrambler::truncatable
virtual bool truncatable(const infinint &pos) const override
whether the implementation is able to truncate to the given position
Definition scrambler.hpp:60
libdar::scrambler::skip
virtual bool skip(const infinint &pos) override
skip at the absolute position
Definition scrambler.hpp:57
libdar::scrambler::skip_relative
virtual bool skip_relative(S_I x) override
skip relatively to the current position
Definition scrambler.hpp:59
libdar::scrambler::inherited_truncate
virtual void inherited_truncate(const infinint &pos) override
truncate file at the give offset
Definition scrambler.hpp:67
libdar::scrambler::inherited_read
virtual U_I inherited_read(char *a, U_I size) override
implementation of read() operation
libdar::secu_string
class secu_string
Definition secu_string.hpp:54
erreurs.hpp
contains all the excetion class thrown by libdar
generic_file.hpp
class generic_file is defined here as well as class fichier
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47
secu_string.hpp
this file contains the definition of secu_string class, a std::string like class but allocated in sec...